var express = require('express');
var router = express.Router();


var auth = function (req, res, next) {
	var cert = req.cert;
	if (cert.account.roles.indexOf('master') > -1) {
		next();
	} else {
		res.render('system/login');
	}
};

/* GET home page. */
router.get('/', auth, function (req, res, next) {
	Db.Config.findOne({}, function(err, config) {
		if (err) {
			throw err;
		}
		res.render('system/master', {
			config : config,
			sexs : BASE_CONFIG.sexs,
			menus : req.menus,
			title : '主管管理',
		});
	});
});

module.exports = router;
